package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.*;
import com.zfzs.post.service.IndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 首页
 *
 * @author ck
 * @date 2018-11-23
 */
@Slf4j
@RestController
@RequestMapping("index/")
public class IndexController {

    @Autowired
    private IndexService indexService;

    /**
     * 首页顶部信息
     */
    @Log("首页顶部信息")
    @PostMapping(value = "get_index_top_info")
    public ResponseResult getIndexTopInfo(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getIndexTopInfo(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 采购新增查询
     */
    @Log("采购新增查询")
    @PostMapping(value = "get_shop_add_list")
    public ResponseResult getShopAddList(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getShopAddList(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 采购新增查询-单个总明细
     */
    @Log("采购新增查询-单个总明细")
    @PostMapping(value = "get_shop_add_info_page")
    public ResponseResult getShopAddInfoPage(@Validated @RequestBody QueryPageDateTypeDTO dto) {
        Map<String, Object> map = indexService.getShopAddInfoPage(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 采购订单明细
     */
    @Log("采购订单明细")
    @PostMapping(value = "get_shop_add_info")
    public ResponseResult getShopAddInfo(@Validated @RequestBody QueryGoodsInfoDTO dto) {
        Map<String, Object> map = indexService.getShopAddInfo(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 流水统计
     */
    @Log("流水统计")
    @PostMapping(value = "get_transaction_sum")
    public ResponseResult getTransactionSum(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getTransactionSum(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 首页底部轮播图信息
     */
    @Log("首页底部信息")
    @PostMapping(value = "get_index_bottom_info")
    public ResponseResult getIndexBottomInfo(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getIndexBottomInfo(dto);
        return ResponseResult.ok(map);
    }

    @Log("首页底部图表信息信息")
    @PostMapping(value = "get_index_bottom_chart")
    public ResponseResult getIndexBottomChart(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getIndexBottomChart(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 拓展个人信息
     */
    @Log("拓展个人信息")
    @PostMapping(value = "get_expand_info")
    public ResponseResult getExpandInfo() {
        Map<String, Object> map = indexService.getExpandInfo();
        return ResponseResult.ok(map);
    }

    /**
     * 商户新增列表
     */
    @Log("商户新增列表")
    @PostMapping(value = "get_add_merchant_list")
    public ResponseResult getAddMerchantList(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getAddMerchantList(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 商户新增列表-分页
     */
    @Log("商户新增列表-分页")
    @PostMapping(value = "get_add_merchant_page")
    public ResponseResult getAddMerchantPage(@Validated @RequestBody QueryPageDateTypeDTO dto) {
        Map<String, Object> map = indexService.getAddMerchantPage(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 商户新增列表明细
     */
    @Log("商户新增列表明细")
    @PostMapping(value = "get_add_merchant_info_list")
    public ResponseResult getAddMerchantInfoList(@Validated @RequestBody AddMerchantInfoDTO dto) {
        Map<String, Object> map = indexService.getAddMerchantInfoList(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 团队新增列表
     */
    @Log("团队新增列表")
    @PostMapping(value = "get_add_agent_list")
    public ResponseResult getAddAgentList(@Validated @RequestBody DateTypeDTO dto) {
        Map<String, Object> map = indexService.getAddAgentList(dto);
        return ResponseResult.ok(map);
    }

    /**
     * 团队新增列表明细
     */
    @Log("团队新增列表明细")
    @PostMapping(value = "get_add_agent_info_list")
    public ResponseResult getAddAgentInfoList(@Validated @RequestBody AddAgentInfoDTO dto) {
        Map<String, Object> map = indexService.getAddAgentInfoList(dto);
        return ResponseResult.ok(map);
    }
}
